import { ADMIN_ADD, ADMIN_ALL, ADMIN_EDIT } from '../actionTypes';

const initialState = {
  loading: false,
  all: [],
  edit: {
    name: '',
    type: '',
    avatar: 'http://owb31aecn.bkt.clouddn.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20171015170049.jpg?nsukey=ZhNX1UO8NceOaw5%2FeRugFDfSah9NTlqCLR%2Bv7fJpWuUxpiKURe6mPpCZFTygji1O6qU8unR5LuSLWGUmo%2FFpv4xG6bSufqbC1IaxobiUXo32%2FLWcaz6%2F3Y%2F6ssPf73Shck3bhfjYP5PIo5iOhq3MLh%2F%2FcZKwAjAJ8SyVMPTPNWI%3D',
    content: [],
  },
  add: {
    name: '',
    type: '',
    avatar: 'http://owb31aecn.bkt.clouddn.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20171015170049.jpg?nsukey=ZhNX1UO8NceOaw5%2FeRugFDfSah9NTlqCLR%2Bv7fJpWuUxpiKURe6mPpCZFTygji1O6qU8unR5LuSLWGUmo%2FFpv4xG6bSufqbC1IaxobiUXo32%2FLWcaz6%2F3Y%2F6ssPf73Shck3bhfjYP5PIo5iOhq3MLh%2F%2FcZKwAjAJ8SyVMPTPNWI%3D',
    content: []
  },
};

const lesson = (state = initialState, action) => {
  switch (action.type) {
    case ADMIN_ALL:
      return {
        ...state,
        all: [...action.payload],
      };
    case ADMIN_ADD:
      return {
        ...state,
        add: { ...state.add, ...action.payload }
      };
    case ADMIN_EDIT:
      return {
        ...state,
        edit: { ...state.edit, ...action.payload },
      };
    default:
      return state;
  }
};

export default lesson;
